<?php
//list our membershp
$top = $page * $limit;
$l = $limit;
if ($top > $count) { 
	$top = $count;
	$l = $count - (($page-1) * $limit);
}

?>
<h4>Showing <?=$names[$authType]?> <?=($page - 1) * $limit + 1?> - <?=$top?> out of <?=$count?></h4>
<?php
	$name = ($authType == AUTH_PROD) ? 'business_name' : 'last_name';
	echo '<h5>', $members[0]['Member'][$name], ' - ', $members[$l-1]['Member'][$name], '</h5>';
	$pages = ceil($count / $limit);
	if ($pages > 1) {
		$plinks = array();
		for($i = 1; $i <= $pages; $i++) {
			$plinks[] = ($i == $page) ? '<span class="current">' . $i . '</span>' : $html->link($i, '/members/show/' . $authType . '/' . $i);
		}
		echo '<p>Go to page: ',join(' ', $plinks), '</p>';
	}
?>
<div class="startTime">
<table>
<tr><th>ID</th><th>Member Info</th><th>Actions</th></tr>
<?php

$quicklinks = array();

foreach($members as $n => $member) {
  $m = $member['Member'];
  $p = $member['Producer'];
  echo '<tr><td>' . $m['member_id'] . '</td>' . "\n";
  echo '<td><a name="'. $m['member_id'] . '"></a>';
	echo $this->renderElement('memberVcard',array('m' => $m));
  echo '</td><td><ul>';
  if ($current_user['auth_type'] == 'administrator') {
    foreach($actions as $auth_level) {
      foreach($auth_level as $auth) {
        if (isset($auth[3])) {
          $m[$auth[2]] = ($auth[3] == AUTH_PROD) ? $p[$auth[2]] : $m[$auth[3]][$auth[2]];
        }
        $link = (isset($auth[2])) ? $auth[1] . $m[$auth[2]] : $auth[1];
        echo '<li>' . $html->link($auth[0],$link) . "</li>\n";
      }
    }
  } else {
    foreach($actions[$current_user['auth_type']] as $auth) {
    //print_r($auth);
      if (isset($auth[3])) {
        $m[$auth[2]] = ($auth[3] == AUTH_PROD) ? $p[$auth[2]] : $m[$auth[3]][$auth[2]];
      }
      $link = (isset($auth[2])) ? $auth[1] . $m[$auth[2]] : $auth[1];
      echo '<li>' . $html->link($auth[0],$link) . "</li>\n";
    }
  }
  echo "</ul></td></tr>\n";

	$quicklinks[] = '<a href="#'. $m['member_id'] . '">' . $m[$name] . '</a>';
}

$this->set('quicklinks', $quicklinks);
?>
</table>
</div>